package com.kotlin.tsw.usercenter.service.impl

import com.kotlin.tsw.baselibrary.rx.BaseFunc
import com.kotlin.tsw.baselibrary.rx.BaseFuncBoolean
import com.kotlin.tsw.usercenter.data.protocol.UserInfo
import com.kotlin.tsw.usercenter.data.repository.UserRepository
import com.kotlin.tsw.usercenter.service.UserService
import rx.Observable
import javax.inject.Inject

class UserServiceImpl @Inject constructor() : UserService {
    @Inject
    lateinit var repository: UserRepository

    /**
     * 注册
     * */
    override fun register(mobile: String, verifyCode: String, pwd: String): Observable<Boolean> {
        return repository.register(mobile, pwd, verifyCode).flatMap(BaseFuncBoolean())
    }

    /**
     * 登录
     * */
    override fun login(mobile: String, pwd: String, pushId: String): Observable<UserInfo> {
        return repository.login(mobile, pwd, pushId).flatMap(BaseFunc())
    }

    /**
     * 验证
     * */
    override fun forgetPwd(mobile: String, verifyCode: String ): Observable<Boolean> {
        return repository.forgetPwd(mobile,verifyCode ).flatMap(BaseFuncBoolean())
    }

    /**
     * 修改
     * */
    override fun resetPwd(mobile: String, pwd: String): Observable<Boolean> {
        return repository.resetPwd(mobile, pwd).flatMap(BaseFuncBoolean())
    }

    /**
     * 修改用户信息
     * */
    override fun editUser(userIcon:String ,userName:String,userMobile:String ,userGender:String ,userSign:String): Observable<UserInfo> {
        return repository.editUser(userIcon ,userName,userMobile ,userGender ,userSign).flatMap(BaseFunc())
    }
}